<template>
  <div class="h2">
    <div class="h2-search" style="margin-top: 15px">
      <el-input
        placeholder="请输入内容"
        v-model="startValue"
        class="input-with-select"
      >
        <template #append>
          <el-button>发起任务</el-button>
        </template>
      </el-input>
    </div>
    <div class="h2-content">
      <el-row :gutter="10">
        <el-col :span="9"
          ><div class="h2-content_stock">
            <h3>常用模板</h3>
            <el-table
              :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
              :data="tableData"
              style="width: 100%"
              border
            >
              <el-table-column prop="tempNum" label="模板编号" width="180">
              </el-table-column>
              <el-table-column prop="tempName" label="模板名称" width="300">
              </el-table-column>
              <el-table-column label="操作">
                <template #default="scope">
                  <el-button @click="handleClick(scope.row)" size="small"
                    >发起合同</el-button
                  >
                </template>
              </el-table-column>
            </el-table>
          </div></el-col
        >
        <el-col :span="12"
          ><div class="h2-content_save">
            <el-row>
              <el-col :span="12"
                ><div class="grid-content bg-purple">
                  <h3>所有可发起模板</h3>
                </div></el-col
              >
              <el-col :span="10"
                ><div class="grid-content bg-purple-light">
                  <el-input
                    placeholder="请输入内容"
                    v-model="searchValue"
                    class="input-with-select"
                  >
                    <template #append>
                      <el-button>搜索</el-button>
                    </template>
                  </el-input>
                </div></el-col
              >
            </el-row>

            <el-table
              :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
              :data="savaTempData"
              style="width: 100%"
              border
            >
              <el-table-column prop="tempNum" label="模板编号" width="180">
              </el-table-column>
              <el-table-column prop="tempName" label="模板名称" width="300">
              </el-table-column>
              <el-table-column label="操作">
                <template #default="scope">
                  <el-button @click="handleClick(scope.row)" size="small"
                    >发起任务</el-button
                  >
                </template>
              </el-table-column>
            </el-table>
            <el-pagination
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="currentPage"
              :page-sizes="[15, 20, 25, 30]"
              :page-size="15"
              layout="total, sizes, prev, pager, next, jumper"
              :total="100"
            >
            </el-pagination></div
        ></el-col>
      </el-row>
    </div>

    <!-- 合同弹出框 -->
    <el-dialog title="发起合同-业务流选择" v-model="contractDialog" center>
      <div class="follow-info">
        <div class="follow-info_top">
          <span>已选模板:</span>
          <p>信托10年规范合同</p>
        </div>
      </div>
      <el-table
        :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
        :data="businessData"
        @selection-change="handleSelectionChange"
        class="follow-table"
        border
        stripe
      >
        <el-table-column type="selection" width="55"> </el-table-column>

        <el-table-column
          property="businessName"
          label="业务流名称"
        ></el-table-column>

        <el-table-column property="account" label="说明"></el-table-column>
      </el-table>

      <div class="business-btn">
        <el-button type="primary" @click="sumitContract">确认发起</el-button>
        <el-button type="primary" @click="removeContractDialog">取消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      searchValue: "",
      startValue: "",
      savaTempData: [
        {
          id: 1,
          tempNum: "rw123456",
          tempName: "冠群信息(南京)技术有限公司",
        },
      ],
      tableData: [
        {
          id: 1,
          tempNum: "rw123456",
          tempName: "冠群信息技术有限公司",
        },
      ],
      contractDialog: false,
      businessData: [
        {
          businessName: "直签模式",
          account: "合同模板无法修改,填写后直接签属",
        },
        {
          businessName: "直签模式",
          account: "合同模板无法修改,填写后直接签属",
        },
        {
          businessName: "直签模式",
          account: "合同模板无法修改,填写后直接签属",
        },
      ],
      businessVal: [],
    };
  },
  methods: {
    handleClick(row) {
      console.log(row);
      this.contractDialog = true;
    },
    handleSelectionChange(val) {
      console.log(val);
      this.businessVal = val;
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
    // 发起合同
    sumitContract() {
      console.log(this.businessVal);
    },
    // 隐藏弹框
    removeContractDialog() {
      this.contractDialog = false;
    },
  },
};
</script>

<style lang="scss" scoped>
.h2-search {
  width: 400px;
  height: 60px;
}
.h2-content {
  width: 100%;
  overflow-x: hidden;
}
.bg-purple-light {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  width: 100%;
}
.follow-info_top {
  display: flex;
  align-items: center;
  p {
    font-weight: 600;
  }
}
.business-btn {
  margin-top: 20px;
}
</style>